package com.adee.netty.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import java.util.Random;

public class NettyClientHandler2 extends ChannelInboundHandlerAdapter {
    // 通道就绪就会触发该方法
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        int i = new Random().nextInt();
//        MyDataInfo.MyMessage myMessage = null;
//        if(0 == i) {
//            myMessage = MyDataInfo.MyMessage.newBuilder()
//                    .setDataType(MyDataInfo.MyMessage.DataType.TeacherType)
//                    .setTeacher(MyDataInfo.Teacher.newBuilder().setId(3).setName("Rosy").build())
//                    .build();
//        } else {
//            myMessage = MyDataInfo.MyMessage.newBuilder()
//                    .setDataType(MyDataInfo.MyMessage.DataType.WorkerType)
//                    .setWorker(MyDataInfo.Worker.newBuilder().setAge(30).setName("Hanmei").build())
//                    .build();
//        }
//        ctx.channel().writeAndFlush(myMessage);
    }
}
